Allow sorting of tree models to be turned off again. (#151139, Torsten
authorMatthias Clasen <maclas@gmx.de>
Sun, 5 Sep 2004 05:06:05 +0000 (05:06 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 5 Sep 2004 05:06:05 +0000 (05:06 +0000)
Sun Sep  5 01:04:01 2004  Matthias Clasen  <maclas@gmx.de>

Allow sorting of tree models to be turned off
again.  (#151139, Torsten Schoenfeld)

* gtk/gtktreesortable.h:
Add GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.

* gtk/gtktreestore.c (gtk_tree_store_sort):
* gtk/gtkliststore.c (gtk_list_store_sort): Don't sort if
the list store is not sorted.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkliststore.c
gtk/gtktreesortable.h
gtk/gtktreestore.c

index 6bd5a9b5a2f7bdd7d9eb6850f7eff06398e8ea5e..2520f15fa42d96755df70886a9b5cf646d391a6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Sun Sep  5 01:04:01 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Allow sorting of tree models to be turned off 
+       again.  (#151139, Torsten Schoenfeld)
+       
+       * gtk/gtktreesortable.h: 
+       Add GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
+
+       * gtk/gtktreestore.c (gtk_tree_store_sort): 
+       * gtk/gtkliststore.c (gtk_list_store_sort): Don't sort if
+       the list store is not sorted.
+
 Sat Sep  4 23:37:56 2004  Matthias Clasen  <maclas@gmx.de>
 
        * configure.in: Fix the Solaris Xinerama checks.  (#151754)
index 6bd5a9b5a2f7bdd7d9eb6850f7eff06398e8ea5e..2520f15fa42d96755df70886a9b5cf646d391a6a 100644 (file)
@@ -1,3 +1,15 @@
+Sun Sep  5 01:04:01 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Allow sorting of tree models to be turned off 
+       again.  (#151139, Torsten Schoenfeld)
+       
+       * gtk/gtktreesortable.h: 
+       Add GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
+
+       * gtk/gtktreestore.c (gtk_tree_store_sort): 
+       * gtk/gtkliststore.c (gtk_list_store_sort): Don't sort if
+       the list store is not sorted.
+
 Sat Sep  4 23:37:56 2004  Matthias Clasen  <maclas@gmx.de>
 
        * configure.in: Fix the Solaris Xinerama checks.  (#151754)
index 6bd5a9b5a2f7bdd7d9eb6850f7eff06398e8ea5e..2520f15fa42d96755df70886a9b5cf646d391a6a 100644 (file)
@@ -1,3 +1,15 @@
+Sun Sep  5 01:04:01 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Allow sorting of tree models to be turned off 
+       again.  (#151139, Torsten Schoenfeld)
+       
+       * gtk/gtktreesortable.h: 
+       Add GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
+
+       * gtk/gtktreestore.c (gtk_tree_store_sort): 
+       * gtk/gtkliststore.c (gtk_list_store_sort): Don't sort if
+       the list store is not sorted.
+
 Sat Sep  4 23:37:56 2004  Matthias Clasen  <maclas@gmx.de>
 
        * configure.in: Fix the Solaris Xinerama checks.  (#151754)
index 6bd5a9b5a2f7bdd7d9eb6850f7eff06398e8ea5e..2520f15fa42d96755df70886a9b5cf646d391a6a 100644 (file)
@@ -1,3 +1,15 @@
+Sun Sep  5 01:04:01 2004  Matthias Clasen  <maclas@gmx.de>
+
+       Allow sorting of tree models to be turned off 
+       again.  (#151139, Torsten Schoenfeld)
+       
+       * gtk/gtktreesortable.h: 
+       Add GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
+
+       * gtk/gtktreestore.c (gtk_tree_store_sort): 
+       * gtk/gtkliststore.c (gtk_list_store_sort): Don't sort if
+       the list store is not sorted.
+
 Sat Sep  4 23:37:56 2004  Matthias Clasen  <maclas@gmx.de>
 
        * configure.in: Fix the Solaris Xinerama checks.  (#151754)
index 9146168b7c7b99ba1e308c11bbe274d3cb949d71..b4dc32031a6b37671d0b250d09c8366dc3491933 100644 (file)
@@ -27,7 +27,7 @@
 #include "gtktreednd.h"
 #include "gtksequence.h"
 
-#define GTK_LIST_STORE_IS_SORTED(list) (GTK_LIST_STORE (list)->sort_column_id != -2)
+#define GTK_LIST_STORE_IS_SORTED(list) (GTK_LIST_STORE (list)->sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID)
 #define VALID_ITER(iter, list_store) ((iter)!= NULL && (iter)->user_data != NULL && list_store->stamp == (iter)->stamp && !_gtk_sequence_ptr_is_end ((iter)->user_data) && _gtk_sequence_ptr_get_sequence ((iter)->user_data) == list_store->seq)
 
 static void         gtk_list_store_init            (GtkListStore      *list_store);
@@ -1650,7 +1650,8 @@ gtk_list_store_sort (GtkListStore *list_store)
   GtkTreePath *path;
   GHashTable *old_positions;
 
-  if (_gtk_sequence_get_length (list_store->seq) <= 1)
+  if (!GTK_LIST_STORE_IS_SORTED (list_store) ||
+      _gtk_sequence_get_length (list_store->seq) <= 1)
     return;
 
   old_positions = save_positions (list_store->seq);
@@ -1716,19 +1717,22 @@ gtk_list_store_set_sort_column_id (GtkTreeSortable  *sortable,
       (list_store->order == order))
     return;
 
-  if (sort_column_id != GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
+  if (sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID)
     {
-      GtkTreeDataSortHeader *header = NULL;
+      if (sort_column_id != GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
+       {
+         GtkTreeDataSortHeader *header = NULL;
 
-      header = _gtk_tree_data_list_get_header (list_store->sort_list, sort_column_id);
+         header = _gtk_tree_data_list_get_header (list_store->sort_list, sort_column_id);
 
-      /* We want to make sure that we have a function */
-      g_return_if_fail (header != NULL);
-      g_return_if_fail (header->func != NULL);
-    }
-  else
-    {
-      g_return_if_fail (list_store->default_sort_func != NULL);
+         /* We want to make sure that we have a function */
+         g_return_if_fail (header != NULL);
+         g_return_if_fail (header->func != NULL);
+       }
+      else
+       {
+         g_return_if_fail (list_store->default_sort_func != NULL);
+       }
     }
 
 
index a84a664f817b872d2bf5c9fe4930c68e0090dcd7..dd7282a192876658c2604a7b1c8798cd0863dede 100644 (file)
@@ -33,7 +33,8 @@ G_BEGIN_DECLS
 #define GTK_TREE_SORTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_TREE_SORTABLE, GtkTreeSortableIface))
 
 enum {
-  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID = -1
+  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID = -1,
+  GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID = -2
 };
 
 typedef struct _GtkTreeSortable      GtkTreeSortable; /* Dummy typedef */
index b3e2409953d83dbfce3d0838f88ddae30c6d4373..c8cc9cd1fb4107bac24c0b577ff051e52221f459 100644 (file)
@@ -27,7 +27,7 @@
 #include "gtktreednd.h"
 
 #define G_NODE(node) ((GNode *)node)
-#define GTK_TREE_STORE_IS_SORTED(tree) (GTK_TREE_STORE (tree)->sort_column_id != -2)
+#define GTK_TREE_STORE_IS_SORTED(tree) (GTK_TREE_STORE (tree)->sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID)
 #define VALID_ITER(iter, tree_store) (iter!= NULL && iter->user_data != NULL && tree_store->stamp == iter->stamp)
 
 static void         gtk_tree_store_init            (GtkTreeStore      *tree_store);
@@ -2555,8 +2555,6 @@ gtk_tree_store_sort_helper (GtkTreeStore *tree_store,
       return;
     }
 
-  g_assert (GTK_TREE_STORE_IS_SORTED (tree_store));
-
   list_length = 0;
   for (tmp_node = node; tmp_node; tmp_node = tmp_node->next)
     list_length++;
@@ -2615,6 +2613,9 @@ gtk_tree_store_sort_helper (GtkTreeStore *tree_store,
 static void
 gtk_tree_store_sort (GtkTreeStore *tree_store)
 {
+  if (!GTK_TREE_STORE_IS_SORTED (tree_store))
+    return;
+
   if (tree_store->sort_column_id != -1)
     {
       GtkTreeDataSortHeader *header = NULL;
@@ -2857,19 +2858,22 @@ gtk_tree_store_set_sort_column_id (GtkTreeSortable  *sortable,
       (tree_store->order == order))
     return;
 
-  if (sort_column_id != GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
+  if (sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID)
     {
-      GtkTreeDataSortHeader *header = NULL;
+      if (sort_column_id != GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
+       {
+         GtkTreeDataSortHeader *header = NULL;
 
-      header = _gtk_tree_data_list_get_header (tree_store->sort_list, sort_column_id);
+         header = _gtk_tree_data_list_get_header (tree_store->sort_list, sort_column_id);
 
-      /* We want to make sure that we have a function */
-      g_return_if_fail (header != NULL);
-      g_return_if_fail (header->func != NULL);
-    }
-  else
-    {
-      g_return_if_fail (tree_store->default_sort_func != NULL);
+         /* We want to make sure that we have a function */
+         g_return_if_fail (header != NULL);
+         g_return_if_fail (header->func != NULL);
+       }
+      else
+       {
+         g_return_if_fail (tree_store->default_sort_func != NULL);
+       }
     }
 
   tree_store->sort_column_id = sort_column_id;